<template>
	<view class="equipment">
		<u-sticky bgColor="#fff">
			<view class="u-page__tag-item">
				<text class="tit"></text>
				<view class="" style="display: flex;">
					<text @click="openPicker" class="input">
						{{addressData.addressName}}
					</text>
					<u-icon name="arrow-down" color="#2979ff" size="18"></u-icon>
				</view>
			</view>
		</u-sticky>

		<scroll-view scroll-y="true">
			<view v-if="textaddress!=''">
				<view class="equipment_box">
					<view class="equipment_list">
						<view>

							<view class="equipment_item black">
								<view class="l">
									<view class="center_info">
										<view class="text1">
											{{textaddress ? textaddress: ''}}
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view v-else>
				<view class="noneDate_box">
					<image src="/static/newProject/equipment_none.png" mode=""></image>
					<view class="button">
						{{$t('node.name20')}}
					</view>
				</view>
			</view>
		</scroll-view>
		<lotus-address v-on:choseVal="choseValue" :lotusAddressData="lotusAddressData"></lotus-address>
	</view>
</template>

<script>
	import lotusAddress from "@/pageA/components/Winglau14-lotusAddress/Winglau14-lotusAddress.vue";
	export default {
		components: {
			"lotus-address": lotusAddress
		},
		data() {
			return {
				list: [],
				page: 1,
				limit: 20,
				equipmentInfo: {
					count: 0
				},
				search: '',
				addressData: {
					name: '',
					phone: '',
					addressName: this.$t('node.name21'),
					address: '',
					area: '',
					status: true
				},
				lotusAddressData: {
					visible: false,
					provinceName: '',
					cityName: '',
					townName: '',
				},
				address: [],
				textaddress: ''
			}
		},
		onLoad(options) {
			uni.setNavigationBarTitle({
				title: options.name
			})
			this.list = []
			this.page = 1
			// this.getUserSnList(this.page, this.limit)
		},
		onReachBottom() {
			if (this.page != 1) {
				this.getUserSnList(this.page, this.limit)
			}
		},
		onNavigationBarButtonTap(e) {
			this.$fun.jump('/pageC/add')
		},
		// onShow() {

		// },
		methods: {
			//打开picker
			openPicker() {
				this.lotusAddressData.visible = true;
				// this.lotusAddressData.provinceName = '河南省';
				// this.lotusAddressData.cityName = '郑州市';
				// this.lotusAddressData.townName = '中原区';
			},
			//回传已选的省市区的值
			choseValue(res) {
				//res数据源包括已选省市区与省市区code
				//console.log(res);
				this.lotusAddressData.visible = res.visible; //visible为显示与关闭组件标识true显示false隐藏
				//res.isChose = 1省市区已选 res.isChose = 0;未选
				if (res.isChose) {
					this.lotusAddressData.provinceName = res.province;
					this.lotusAddressData.cityName = res.city;
					this.lotusAddressData.townName = res.town;
					this.addressData.addressName = `${res.province} ${res.city} ${res.town}`; //region为已选的省市区的值
					this.addressData.address = `${res.province} ${res.city} ${res.town}`; //region为已选的省市区的值
					this.address = [res.province, res.city, res.town]
					this.getUserSnList()
				}
			},
			jump(url) {
				this.$fun.jump(url)
			},
			getUserSnList(page, limit) {
				this.$fun.ajax.post('user/getAgentData', {
					area: this.address
				}).then(res => {
					this.textaddress = res.data
				})
			}
		}
	}
</script>

<style lang="scss">
	.equipment {
		.u-page__tag-item {
			padding: 20rpx 10rpx;
		}

		.top_equipment {
			width: 100%;
			height: 180rpx;
			background: #F6F6F6;
			box-sizing: border-box;
			padding: 0 40rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.top_item {
				width: 150rpx;
				height: 150rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.05);
				border-radius: 10rpx;
				position: relative;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				font-family: Microsoft YaHei;
				color: #333333;
				font-size: 30rpx;

				.num {
					margin-bottom: 20rpx;
					font-weight: bold;
				}

				.circular {
					position: absolute;
					top: 15rpx;
					right: 15rpx;
					width: 15rpx;
					height: 15rpx;
					border-radius: 50%;
				}
			}
		}

		.equipment_box {
			padding: 41rpx 30rpx;

			.top_box {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.l {
					display: flex;
					align-items: center;

					image {
						margin-left: 13rpx;
						margin-right: 10rpx;
						width: 33rpx;
						height: 38rpx;
					}

					text {
						font-size: 20rpx;
						font-family: Microsoft YaHei;
						font-weight: bold;
						color: #333333;
					}
				}

				.r {
					font-size: 20rpx;
					font-family: Microsoft YaHei;
					font-weight: bold;
					color: #333333;
				}
			}

			.cenetr_box {
				margin-top: 29rpx;
				height: 80rpx;
				background: #EEEEEE;
				border-radius: 10px;
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 0 30rpx;
				box-sizing: border-box;

				.l {
					font-size: 20rpx;
					font-family: Microsoft YaHei;
					font-weight: bold;
					color: #333333;
				}

				.r {
					font-size: 20rpx;
					font-family: Microsoft YaHei;
					font-weight: bold;
					color: #5990FF;

					image {
						margin-left: 90rpx;
						width: 24rpx;
						height: 14rpx;
					}
				}
			}

			.equipment_list {
				margin-top: 20rpx;

				.equipment_item {
					margin-bottom: 20rpx;
					width: 100%;
					padding: 25rpx 30rpx;
					border-radius: 10rpx;
					box-sizing: border-box;
					display: flex;
					justify-content: space-between;

					.l {
						display: flex;

						image {
							width: 80rpx;
							height: 80rpx;
							border-radius: 10rpx;
						}

						.center_info {
							margin-left: 14rpx;
							display: flex;
							flex-direction: column;
							// width: 400rpx;

							.text {
								width: 400rpx;
								width: 100%; //固定宽度
								overflow: hidden; //溢出隐藏
								white-space: nowrap; //不换行
								text-overflow: ellipsis; //显示...
							}

						}
					}

					.r {
						display: flex;
						justify-content: flex-end;
						align-items: center;

						text {
							font-size: 24rpx;
							font-family: Microsoft YaHei;
							font-weight: 400;
							color: #5990FF;
						}

						image {
							margin-left: 22rpx;
							width: 14rpx;
							height: 24rpx;
						}
					}
				}

				.gray {
					background: #F6F6F6;
					color: #CCCCCC;
				}

				.black {
					background: #F6F6F6;
					color: #333333;
				}
			}
		}

	}

	.noneDate_box {
		margin-top: 126rpx;
		text-align: center;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

		image {
			width: 309rpx;
			height: 317rpx;
		}

		.button {
			margin: 30rpx 0;
			width: 200rpx;
			height: 60rpx;
			background: linear-gradient(-30deg, #5990FF 0%, #00aaff 100%);
			border-radius: 30rpx;
			font-size: 22rpx;
			font-family: Microsoft YaHei;
			color: #FFFFFF;
			line-height: 60rpx;
			text-align: center;
		}
	}
</style>